import {mathType} from "@/constant/mathConstants";

export class MathModel {
    param1: number = 0;
    param2: number = 0;
    param3?: number;
    // 见 mathConstants.mathType
    type: number = 0;
    // mathStr: string = '';
    typeStr: string = '';
    type2?:number;
    typeStr2?: string;
    result?: any = 0;

    constructor(param1: number, param2: number, type: number) {
        this.param1 = param1;
        this.param2 = param2;
        this.type = type;
    }

    getMath() {
        if (this.type == 1){
            this.typeStr = mathType[0].str;
            this.result = this.param1 + this.param2;
        }else if (this.type == 2){
            this.typeStr = mathType[1].str;
            this.result = this.param1 - this.param2;
        }else if (this.type == 3){
            this.typeStr = mathType[2].str;
            this.result = this.param1 * this.param2;
        }else if (this.type == 4){
            this.typeStr = mathType[3].str;
            this.result = this.param1 * this.param2;
        }else if (this.type == 5){
            this.typeStr = mathType[4].str;
            this.result = this.param1 / this.param2;
        }
        else if (this.type == 6){
            this.typeStr = mathType[5].str;
        }
    }
}
